/**
 * Created by IntelliJ IDEA.
 * User: hubiao
 * DateTime: 2018/7/23 16:59
 **/
package com.blogs.service.log.impl;

import com.blogs.domain.db.Log;
import com.blogs.mapper.LogMapper;
import com.blogs.service.log.LogService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 日志相关Service接口实现
 */
@Service
public class LogServiceImpl implements LogService {


    @Resource
    private LogMapper logDao;


    @Override
    public void addLog(String action, String data, String ip, Integer authorId) {
        Log logDomain = new Log();
        logDomain.setAuthorId( authorId );
        logDomain.setIp( ip );
        logDomain.setData( data );
        logDomain.setAction( action );
        logDao.addLog( logDomain );
    }

    @Override
    public PageInfo<Log> getLogs(int pageNum, int pageSize) {
        PageHelper.startPage( pageNum, pageSize );
        List<Log> logs = logDao.getLogs();
        PageInfo<Log> pageInfo = new PageInfo<>( logs );
        return pageInfo;

    }
}
